

export function getAccessToken() {
	if (typeof(localStorage) !== 'undefined') return localStorage.getItem('user_token')
	else return ''
}

export function setAccessToken(token) {
	if (typeof(localStorage) !== 'undefined') localStorage.setItem('user_token', token)
}

export function removeAccessToken() {
	if (typeof(localStorage) !== 'undefined') localStorage.removeItem('user_token');
}

export function getSecret() {
	if (typeof(localStorage) !== 'undefined') return localStorage.getItem('user_secret')
	else return ''
}

export function setUser(user) {
	if (typeof(localStorage) !== 'undefined' &&  user && typeof(user) === 'object') {
      localStorage.setItem('user_secret', JSON.stringify(user))
      setAccessToken(user.accessToken)
	}
}

export function removeUser() {
	if (typeof(localStorage) !== 'undefined') {
		localStorage.removeItem('user_secret')
		removeAccessToken()
	}
}

export function isLogin() {
	let user = this.getSecret()
	return user || user !== '' || user._id || user._id !== ''
}